package pages

import (
	"github.com/templui/templui/internal/components/card"
	"github.com/templui/templui/internal/ui/layouts"
	"github.com/templui/templui/internal/ui/modules"
	"github.com/templui/templui/internal/ui/showcase"
)

templ Label() {
	@layouts.DocsLayout(
		"Label",
		"Renders an accessible label associated with controls.",
		[]modules.TableOfContentsItem{
			{
				ID:   "installation",
				Text: "Installation",
			},
			{
				ID:   "api",
				Text: "API Reference",
				Children: []modules.TableOfContentsItem{
					{
						ID:   "label",
						Text: "Label",
					},
				},
			},
		},
	) {
		@modules.PageWrapper(modules.PageWrapperProps{
			Name:        "Label",
			Description: templ.Raw("Renders an accessible label associated with controls."),
			Tailwind:    true,
			VanillaJS:   true,
			Breadcrumbs: modules.Breadcrumbs{
				Items: []modules.BreadcrumbItem{
					{
						Text: "Docs",
						Path: "/docs",
					},
					{
						Text: "Components",
						Path: "/docs/components",
					},
					{
						Text: "Label",
					},
				},
			},
		}) {
			@modules.ExampleWrapper(modules.ExampleWrapperProps{
				SectionName:     "",
				ShowcaseFile:    showcase.CheckboxDefault(),
				PreviewCodeFile: "checkbox_default.templ",
			})
			@modules.ContainerWrapper(modules.ContainerWrapperProps{
				Title: "Installation",
				ID:    "installation",
			}) {
				@modules.ComponentUsage(modules.ComponentUsageProps{
					ComponentName: "label",
					JSFiles:       []string{"label"},
				})
			}
			<div>
				@card.Card() {
					@card.Header() {
						@card.Title() {
							Usage
						}
						@card.Description() {
							The Label component enhances the following form controls:
						}
					}
					@card.Content() {
						<ul class="list-disc pl-6 space-y-2">
							<ul class="list-disc pl-6 space-y-2">
								<li>
									<a href="/docs/components/checkbox#with-label" class="font-medium hover:underline">Checkbox</a>
								</li>
								<li>
									<a href="/docs/components/date-picker#with-label" class="font-medium hover:underline">Date Picker</a>
								</li>
								<li>
									<a href="/docs/components/input#with-label" class="font-medium hover:underline">Input</a>
								</li>
								<li>
									<a href="/docs/components/input-otp#with-label" class="font-medium hover:underline">Input OTP</a>
								</li>
								<li>
									<a href="/docs/components/radio#with-label" class="font-medium hover:underline">Radio</a>
								</li>
								<li>
									<a href="/docs/components/select#with-label" class="font-medium hover:underline">Select</a>
								</li>
								<li>
									<a href="/docs/components/textarea#with-label" class="font-medium hover:underline">Textarea</a>
								</li>
								<li>
									<a href="/docs/components/tags-input#with-label" class="font-medium hover:underline">Tags Input</a>
								</li>
								<!-- <li> -->
								<!-- 	<a href="/docs/components/time-picker#with-label" class="font-medium hover:underline">Time Picker</a> -->
								<!-- </li> -->
								<li>
									<a href="/docs/components/toggle#with-label" class="font-medium hover:underline">Toggle</a>
								</li>
								<li>
									<a href="/docs/components/rating#with-label" class="font-medium hover:underline">Rating</a>
								</li>
							</ul>
						</ul>
					}
				}
			</div>
			@modules.ContainerWrapper(modules.ContainerWrapperProps{
				Title: "API Reference",
				ID:    "api",
			}) {
				@modules.APILegend()
				<div id="label" class="mb-8">
					@modules.APITable(modules.APITableProps{
						Title:       "Label",
						Description: "Accessible label component for associating text with form controls.",
						Items: []modules.APITableItem{
							{
								Name:        "ID",
								Type:        "string",
								Default:     "",
								Description: "Unique identifier for the label element.",
								Required:    false,
							},
							{
								Name:        "Class",
								Type:        "string",
								Default:     "",
								Description: "Additional CSS classes to apply to the label.",
								Required:    false,
							},
							{
								Name:        "Attributes",
								Type:        "templ.Attributes",
								Default:     "",
								Description: "Additional HTML attributes to apply to the label element.",
								Required:    false,
							},
							{
								Name:        "For",
								Type:        "string",
								Default:     "",
								Description: "ID of the form control this label is associated with (for attribute).",
								Required:    false,
							},
							{
								Name:        "Error",
								Type:        "string",
								Default:     "",
								Description: "Error message that changes the label styling to indicate validation errors.",
								Required:    false,
							},
						},
					})
				</div>
			}
		}
	}
}
